package lava.rt.linq;

import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

public abstract class LinqExecption  extends Exception{

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


    public static final int CMD_UNKNOW=0
    		,CMD_SQL=1
    		,CMD_REFLECT=2
    		,CMD_LANG=3
    		;


	
	
	final String cmd;
	
	final Object[] param;

	final int cmdType;
	
	final public SortedSet<String> issueStackTrace=new TreeSet<>();
	
	public LinqExecption(String message,int cmdType,String cmd, Object... param) {
		super(message);
		this.cmdType=cmdType;
		this.cmd = cmd;
		this.param = param;
	}
	
	public LinqExecption(Exception e,String cmd, Object... param) {
		super(e);
		this.cmdType=getCmdType(e);
		this.cmd = cmd;
		this.param = param;
	}
	
	

	public LinqExecption(Exception e, int cmdType,String cmd, Object... param) {
		super(e);
		this.cmdType=cmdType;
		this.cmd = cmd;
		this.param = param;
	}

	public LinqExecption(LinqExecption e,String cmd,Object... param) {
		super(e);
		this.cmdType=e.cmdType;
		this.cmd = cmd;
		this.param = param;
	}
	

	
	private int getCmdType(Exception e) {
		int ret=CMD_UNKNOW;
		if(e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
			ret=CMD_REFLECT;
		}else if(e instanceof NumberFormatException) {
			ret=CMD_LANG;
		}
		return ret;
	}

	
	
}
